#include <kernel.h>

extern dde_kit_addr_t *inv_map;
extern spin_lock_t     dk_timer_lock;
extern spin_lock_t     dk_thread_lock;

extern struct dde_kit_thread dk_threads[DK_THREAD_COUNT];

void
LD_SYM(dde_kit_init)(void)
{
	 /* magic! */
	 inv_map = (dde_kit_addr_t *)ekf_alloc(1 << 22);

	 spl_init(&dk_thread_lock);
	 
	 int i;
	 for (i = 0; i != DK_THREAD_COUNT; ++ i)
	 {
		  dk_threads[i].free = 1;
	 }

	 LD_SYM(dde_kit_thread_adopt_myself)("__dde_kitinit");
}

#if DK_EXPORT_SYM

void dde_kit_intr_symbol(void);
void dde_kit_lock_symbol(void);
void dde_kit_memory_symbol(void);
void dde_kit_panic_symbol(void);
void dde_kit_pci_symbol(void);
void dde_kit_pgtab_symbol(void);
void dde_kit_printf_symbol(void);
void dde_kit_resources_symbol(void);
void dde_kit_sem_symbol(void);
void dde_kit_thread_symbol(void);
void dde_kit_timer_symbol(void);

int
dde_kit_symbol(void)
{
	 dde_kit_intr_symbol();
	 dde_kit_lock_symbol();
	 dde_kit_memory_symbol();
	 dde_kit_panic_symbol();
	 dde_kit_pci_symbol();
	 dde_kit_pgtab_symbol();
	 dde_kit_printf_symbol();
	 dde_kit_resources_symbol();
	 dde_kit_sem_symbol();
	 dde_kit_thread_symbol();
	 dde_kit_timer_symbol();

	 elf_mod_export_symbol("dde_kit_init", &dde_kit_init, 1);

	 return 0;
}

#endif
